-
Notifications
You must be signed in to change notification settings - Fork 71
BJS2-77992. Добавлено создание цели #2969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BJS2-77992. Добавлено создание цели #2969
Conversation
FROLOV-KI
commented
May 8, 2025
- Добавлен GoalService
- Добавлен GoalController
- Добавлен GoalMapper
- Добавлены кастомные исключения для сущностей goal и skill 5) Добавлен SkillService
- Добавлен GoalExceptionHandler
1) Добавлен GoalService 2) Добавлен GoalController 3) Добавлен GoalMapper 4) Добавлены кастомные исключения для сущностей goal и skill 5) Добавлен SkillService 6) Добавлен GoalExceptionHandler
1) Вызов маппера перенесен в контроллер 2) Добавлены классы валидаторы
src/main/java/school/faang/user_service/entity/goal/mapper/GoalMapper.java
Show resolved
Hide resolved
src/main/java/school/faang/user_service/exception/goal/MaxActiveGoalPerUserException.java
Show resolved
Hide resolved
src/main/java/school/faang/user_service/repository/goal/GoalRepository.java
Outdated
Show resolved
Hide resolved
1) Удален GoalExceptionHandler.java 2) Добавлен метод удаление связи цель - скилл
src/main/java/school/faang/user_service/validator/goal/SkillValidator.java
Show resolved
Hide resolved
| private final CreateGoalMapperImpl createGoalMapper; | ||
| private final UpdateGoalMapperImpl updateGoalMapper; | ||
|
|
||
| @PostMapping("/create") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PostMapping самодостаточный для create, его лучше без параметров оставить, и по этой url /api/v1/goal делать create
| .body(createGoalMapper.goalToDto(createdGoal)); | ||
| } | ||
|
|
||
| @PutMapping("/update/{goalId}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тоже /update не нужен в пути
| return ResponseEntity.ok(updateGoalMapper.goalToDto(createdGoal)); | ||
| } | ||
|
|
||
| @DeleteMapping("/delete/{goalId}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
И /delete не нужен в пути
src/main/java/school/faang/user_service/controller/goal/GoalController.java
Outdated
Show resolved
Hide resolved
src/main/java/school/faang/user_service/controller/goal/GoalController.java
Outdated
Show resolved
Hide resolved
src/main/java/school/faang/user_service/controller/goal/GoalController.java
Outdated
Show resolved
Hide resolved
src/main/java/school/faang/user_service/controller/goal/GoalController.java
Outdated
Show resolved
Hide resolved
src/main/java/school/faang/user_service/entity/goal/dto/GoalDto.java
Outdated
Show resolved
Hide resolved
src/main/java/school/faang/user_service/service/GoalService.java
Outdated
Show resolved
Hide resolved
src/main/java/school/faang/user_service/validator/goal/GoalValidator.java
Outdated
Show resolved
Hide resolved
src/main/java/school/faang/user_service/validator/goal/GoalValidator.java
Show resolved
Hide resolved
src/main/java/school/faang/user_service/validator/goal/GoalValidator.java
Show resolved
Hide resolved
1) Разделил DTO для создания, обновления и ответа 2) Добавил User сервис 3) Добавил в DTO поле deadline
20cognosce
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нормально, но чересчур многовато получилось для этой задачи, 700 строк
|
|
||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public record UpdateGoalDto( | ||
| @NotBlank(message = "Empty goal title not allowed!") String title, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно не писать подробные сообщения
| @Query(nativeQuery = true, value = """ | ||
| DELETE FROM goal_skill | ||
| WHERE goal_id = :goalId""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше не нативкой это делать, а через JPA
| @Query(nativeQuery = true, value = """ | ||
| DELETE FROM user_goal ug | ||
| WHERE ug.user_id = :userId AND ug.goal_id = :goalId | ||
| """) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
| String notExistingSkillsId = absentSkillsId.stream() | ||
| .map(String::valueOf) | ||
| .collect(Collectors.joining(", ")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот это целое действие только ради лога, такое
| goalRepository.removeGoalFromUser(userContext.getUserId(), goalId); | ||
|
|
||
| if (goalRepository.findUsersByGoalId(goalId).isEmpty()) { | ||
| goalRepository.findByParent(goalId).forEach(goalRepository::delete); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
что со вложенностью-то решили? может сделаешь тогда ограничение, что если у цели есть родитель, то она сама не может быть родителем? чтобы был 1 уровень вложенности